package com.yxkj.syh.app.huarong.adps;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.syh.app.basic.base.BaseAdp;
import com.yxkj.syh.app.huarong.R;
import com.yxkj.syh.app.huarong.bean.NoticeResponse;

/**
 * 创建者：SYH
 * 时间：2020/6/18 11:38
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class NoticeAdp extends BaseAdp<NoticeResponse.Record> {

    private ClickListener mClickListener;

    @Override
    protected RecyclerView.ViewHolder createYourViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_notice_list, parent,false);
        return new ViewHolder(view);
    }

    @Override
    protected void bindYourViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        if (mClickListener != null) {
            holder.itemView.setOnClickListener(v -> {
                mClickListener.onItemClick(mData.get(position));
            });
        }
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.tvTitle.setText(mData.get(position).getName());
        viewHolder.tvTime.setText(mData.get(position).getCreateTime());
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvTime, tvTitle;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvTime = itemView.findViewById(R.id.tvTime);
            tvTitle = itemView.findViewById(R.id.tvTitle);
        }
    }

    public void setclickListener(ClickListener clickListener) {
        this.mClickListener = clickListener;
    }

    public interface ClickListener {
        void onItemClick(NoticeResponse.Record record);
    }

}
